<!DOCTYPE html>
<html>
<head>
    

    
<!-- Tencent Speed -->
<script>var _speedMark = new Date()</script>
<!-- End Tencent Speed -->
<!-- Tencent Analysis -->
<script async src="//tajs.qq.com/stats?sId=65074773"></script>
<!-- End Tencent Analysis -->


    



    <meta charset="utf-8">
    
    
    
    <title>spring boot+shiro+vue前后端分离登陆验证 | 阿喜的博客 | Blog of lfxiui</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="spring boot,登陆验证,vue,shiro">
    <meta name="description" content="spring boot+shiro+vue前后端分离登陆验证问题定义spring boot集成shiro，配置shiro拦截器，验证登陆并返回JSON数据，前端根据响应数据判断是否已经登陆，未登录则跳转至登陆页面，已登陆无法进入登陆页。 解决思路 配置拦截器：集成shiro，用类的方式配置shiro拦截器，重写AuthorizingRealm实现用户密码验证。 验证码：在我之前的文章里实现过了。s">
<meta name="keywords" content="spring boot,登陆验证,vue,shiro">
<meta property="og:type" content="article">
<meta property="og:title" content="spring boot+shiro+vue前后端分离登陆验证">
<meta property="og:url" content="http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/index.html">
<meta property="og:site_name" content="阿喜的博客">
<meta property="og:description" content="spring boot+shiro+vue前后端分离登陆验证问题定义spring boot集成shiro，配置shiro拦截器，验证登陆并返回JSON数据，前端根据响应数据判断是否已经登陆，未登录则跳转至登陆页面，已登陆无法进入登陆页。 解决思路 配置拦截器：集成shiro，用类的方式配置shiro拦截器，重写AuthorizingRealm实现用户密码验证。 验证码：在我之前的文章里实现过了。s">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-01-29T12:48:27.208Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="spring boot+shiro+vue前后端分离登陆验证">
<meta name="twitter:description" content="spring boot+shiro+vue前后端分离登陆验证问题定义spring boot集成shiro，配置shiro拦截器，验证登陆并返回JSON数据，前端根据响应数据判断是否已经登陆，未登录则跳转至登陆页面，已登陆无法进入登陆页。 解决思路 配置拦截器：集成shiro，用类的方式配置shiro拦截器，重写AuthorizingRealm实现用户密码验证。 验证码：在我之前的文章里实现过了。s">
    
        <link rel="alternate" type="application/atom+xml" title="阿喜的博客" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">lfxiui</h5>
          <a href="mailto:806941929@qq.com" title="806941929@qq.com" class="mail">806941929@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/categories"  >
                <i class="icon icon-lg icon-th-list"></i>
                分类
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/lfxiui" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="http://www.weibo.com/" target="_blank" >
                <i class="icon icon-lg icon-weibo"></i>
                微博
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/custom"  >
                <i class="icon icon-lg icon-link"></i>
                测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">spring boot+shiro+vue前后端分离登陆验证</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">spring boot+shiro+vue前后端分离登陆验证</h1>
        <h5 class="subtitle">
            
                <time datetime="2018-01-29T12:43:24.324Z" itemprop="datePublished" class="page-time">
  2018-01-29
</time>


	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/项目经验/">项目经验</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/项目经验/前后端分离/">前后端分离</a></li></ul></li></ul>

            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-1"><a class="post-toc-link" href="#spring-boot-shiro-vue前后端分离登陆验证"><span class="post-toc-number">1.</span> <span class="post-toc-text">spring boot+shiro+vue前后端分离登陆验证</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#问题定义"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">问题定义</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#解决思路"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">解决思路</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#具体实现"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">具体实现</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#shiro拦截器配置"><span class="post-toc-number">1.3.1.</span> <span class="post-toc-text">shiro拦截器配置</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#登陆验证UserRealm"><span class="post-toc-number">1.3.2.</span> <span class="post-toc-text">登陆验证UserRealm</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Controller层实现"><span class="post-toc-number">1.3.3.</span> <span class="post-toc-text">Controller层实现</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Vue判断是否已经登陆"><span class="post-toc-number">1.3.4.</span> <span class="post-toc-text">Vue判断是否已经登陆</span></a></li></ol></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-spring boot+shiro+vue前后端分离登陆验证"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">spring boot+shiro+vue前后端分离登陆验证</h1>
        <div class="post-meta">
            <time class="post-time" title="2018-01-29 20:43:24" datetime="2018-01-29T12:43:24.324Z"  itemprop="datePublished">2018-01-29</time>

            
	<ul class="article-category-list"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/项目经验/">项目经验</a><ul class="article-category-list-child"><li class="article-category-list-item"><a class="article-category-list-link" href="/categories/项目经验/前后端分离/">前后端分离</a></li></ul></li></ul>



            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h1 id="spring-boot-shiro-vue前后端分离登陆验证"><a href="#spring-boot-shiro-vue前后端分离登陆验证" class="headerlink" title="spring boot+shiro+vue前后端分离登陆验证"></a>spring boot+shiro+vue前后端分离登陆验证</h1><h2 id="问题定义"><a href="#问题定义" class="headerlink" title="问题定义"></a>问题定义</h2><p>spring boot集成shiro，配置shiro拦截器，验证登陆并返回JSON数据，前端根据响应数据判断是否已经登陆，未登录则跳转至登陆页面，已登陆无法进入登陆页。</p>
<h2 id="解决思路"><a href="#解决思路" class="headerlink" title="解决思路"></a>解决思路</h2><ul>
<li><strong>配置拦截器</strong>：集成shiro，用类的方式配置shiro拦截器，重写AuthorizingRealm实现用户密码验证。</li>
<li><strong>验证码</strong>：在我之前的文章里实现过了。<a href="http://lfxiui.gitee.io/2018/01/27/spring%20boot%E5%89%8D%E5%90%8E%E7%AB%AF%E5%88%86%E7%A6%BB%E5%AE%9E%E7%8E%B0%E9%AA%8C%E8%AF%81%E7%A0%81%E5%8A%9F%E8%83%BD/">spring boot前后端分离实现验证码功能</a></li>
<li><strong>axios拦截器</strong>：安装<a href="https://github.com/axios/axios" target="_blank" rel="noopener">axios</a>，vue全局引入，对axios的响应数据处理，判断是否已经登陆，已经登陆则返回响应数据，未登录则跳转到登陆页。</li>
<li><strong>vue-router</strong>：配置在挑战至登陆页前先发送请求到后端，查询是否已经登陆，已经登陆则跳转至首页，否则跳转至登陆页。</li>
</ul>
<h2 id="具体实现"><a href="#具体实现" class="headerlink" title="具体实现"></a>具体实现</h2><h3 id="shiro拦截器配置"><a href="#shiro拦截器配置" class="headerlink" title="shiro拦截器配置"></a>shiro拦截器配置</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Configuration</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ShiroConfiguration</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> ShiroFilterFactoryBean <span class="title">shiroFilterFactoryBean</span><span class="params">(SecurityManager securityManager)</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"&gt;&gt;&gt;shiro拦截器&lt;&lt;&lt;"</span>);</span><br><span class="line">        ShiroFilterFactoryBean shiroFilterFactoryBean = <span class="keyword">new</span> ShiroFilterFactoryBean();</span><br><span class="line">        shiroFilterFactoryBean.setSecurityManager(securityManager);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//拦截器</span></span><br><span class="line">        Map&lt;String, String&gt; filterChainDefinitionMap = <span class="keyword">new</span> LinkedHashMap&lt;&gt;();</span><br><span class="line"></span><br><span class="line">        <span class="comment">//配置不会被拦截的链接 顺序判断</span></span><br><span class="line">        <span class="comment">//首先是静态资源 注:spring boot默认静态资源在static文件夹所以这里用/static/**不行，根据自己的实际情况修改</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/css/**"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/fonts/**"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/img/**"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/js/**"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//防止拦截首页</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//配置退出过滤器，其中退出的具体代码由shiro实现</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/logout"</span>, <span class="string">"logout"</span>);</span><br><span class="line">        <span class="comment">//登陆</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/user/login"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//注册</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/user/signup"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//判断是否已经登陆</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/user/isLogin"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//获取验证码</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/user/getVCodePic"</span>, <span class="string">"anon"</span>);</span><br><span class="line">        <span class="comment">//过滤链定义，从上向下顺序执行，一般将/**放在最为下边</span></span><br><span class="line">        <span class="comment">//authc:所有url都必须认证通过才可以访问; anon:所有url都都可以匿名访问</span></span><br><span class="line">        filterChainDefinitionMap.put(<span class="string">"/**"</span>, <span class="string">"authc"</span>);</span><br><span class="line">        <span class="comment">//未登录，如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面</span></span><br><span class="line">        <span class="comment">//仍然是通过controller请求响应</span></span><br><span class="line">        shiroFilterFactoryBean.setLoginUrl(<span class="string">"/user/unauth"</span>);</span><br><span class="line">        </span><br><span class="line">        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);</span><br><span class="line">        <span class="keyword">return</span> shiroFilterFactoryBean;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> UserRealm <span class="title">userRealm</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        UserRealm userRealm = <span class="keyword">new</span> UserRealm();</span><br><span class="line">        System.out.println(<span class="string">"&gt;&gt;&gt;UserRealm&lt;&lt;&lt;"</span>);</span><br><span class="line">        <span class="keyword">return</span> userRealm;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Bean</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> SecurityManager <span class="title">securityManager</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        DefaultWebSecurityManager securityManager = <span class="keyword">new</span> DefaultWebSecurityManager();</span><br><span class="line">        securityManager.setRealm(userRealm());</span><br><span class="line">        <span class="keyword">return</span> securityManager;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="登陆验证UserRealm"><a href="#登陆验证UserRealm" class="headerlink" title="登陆验证UserRealm"></a>登陆验证UserRealm</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserRealm</span> <span class="keyword">extends</span> <span class="title">AuthorizingRealm</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> UserService userService;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 权限验证</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> principalCollection</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">protected</span> AuthorizationInfo <span class="title">doGetAuthorizationInfo</span><span class="params">(PrincipalCollection principalCollection)</span> </span>&#123;</span><br><span class="line">        System.out.println(<span class="string">"doGetAuthorizationInfo"</span>);</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 登陆验证</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> authenticationToken</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> AuthenticationException</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">protected</span> AuthenticationInfo <span class="title">doGetAuthenticationInfo</span><span class="params">(AuthenticationToken authenticationToken)</span> <span class="keyword">throws</span> AuthenticationException </span>&#123;</span><br><span class="line">        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;</span><br><span class="line">        User userCheck = <span class="keyword">new</span> User();</span><br><span class="line">        userCheck.setAccount(token.getUsername());</span><br><span class="line">        <span class="comment">//根据账号查询用户信息</span></span><br><span class="line">        User user = userService.getUserByAccount(userCheck);</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">null</span> == user) &#123;</span><br><span class="line">            <span class="comment">//用户不存在，抛出账号异常</span></span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> UnknownAccountException();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//验证交给shiro</span></span><br><span class="line">        <span class="comment">//三个参数为user，密码，realm</span></span><br><span class="line">        <span class="comment">//因为是从表单获得的account，然后拿来查询，比较的是从数据库获取得password和token中获得的password</span></span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> SimpleAuthenticationInfo(</span><br><span class="line">                user,</span><br><span class="line">                user.getPassword(),</span><br><span class="line">                getName()</span><br><span class="line">        );</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="Controller层实现"><a href="#Controller层实现" class="headerlink" title="Controller层实现"></a>Controller层实现</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RestController</span></span><br><span class="line"><span class="meta">@RequestMapping</span>(value = <span class="string">"/user"</span>)</span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">UserController</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Autowired</span></span><br><span class="line">    <span class="keyword">private</span> UserService userService;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 登陆</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> map     &#123;account: 账号, password: 密码, vCode: 验证码&#125;</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@RequestMapping</span>(value = <span class="string">"/login"</span>, method = RequestMethod.POST)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> AjaxResult <span class="title">login</span><span class="params">(@RequestBody Map&lt;String, String&gt; map, HttpServletRequest request)</span> </span>&#123;</span><br><span class="line">        <span class="comment">//验证 验证码</span></span><br><span class="line">        String userVCode = map.get(<span class="string">"vCode"</span>);</span><br><span class="line">        String sessionVCode = request.getSession().getAttribute(<span class="string">"vCode"</span>).toString();</span><br><span class="line">        <span class="keyword">if</span> (!sessionVCode.equalsIgnoreCase(userVCode)) &#123;</span><br><span class="line">            <span class="keyword">return</span> ErrorReturnFormat.retParam(<span class="number">1022</span>, <span class="keyword">null</span>);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//密码加密工具类，我用的是MD5加密，这里不细说了</span></span><br><span class="line">        MyPassword myPassword = <span class="keyword">new</span> MyPassword();</span><br><span class="line">        UsernamePasswordToken token = <span class="keyword">new</span> UsernamePasswordToken(</span><br><span class="line">                map.get(<span class="string">"account"</span>),</span><br><span class="line">                myPassword.getPassword(map.get(<span class="string">"password"</span>), map.get(<span class="string">"account"</span>))</span><br><span class="line">        );</span><br><span class="line">        Subject subject = SecurityUtils.getSubject();</span><br><span class="line">        subject.login(token);</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">200</span>, <span class="string">"登陆成功"</span>, subject.getSession().getId());</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 未登录</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@RequestMapping</span>(value = <span class="string">"/unauth"</span>)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> AjaxResult <span class="title">unauth</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> ErrorReturnFormat.retParam(<span class="number">210</span>, <span class="keyword">null</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 注册</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> user</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@RequestMapping</span>(value = <span class="string">"/signup"</span>, method = RequestMethod.POST)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> AjaxResult <span class="title">signup</span><span class="params">(@RequestBody User user)</span> </span>&#123;</span><br><span class="line">        <span class="comment">//账号长度限制</span></span><br><span class="line">        <span class="keyword">int</span> accountMax = <span class="number">16</span>;</span><br><span class="line">        <span class="keyword">if</span> (accountMax &lt; user.getAccount().length()) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">1016</span>, <span class="string">"账号长度不能超过16位"</span>);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//盐，这里我用账号作为盐</span></span><br><span class="line">        user.setSalt(user.getAccount());</span><br><span class="line">        MyPassword myPassword = <span class="keyword">new</span> MyPassword();</span><br><span class="line">        user.setPassword(myPassword.getPassword(user.getPassword(), user.getSalt()));</span><br><span class="line">        <span class="keyword">if</span> (userService.insertUser(user) &gt; <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">200</span>, <span class="string">"注册成功"</span>);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> ErrorReturnFormat.retParam(<span class="number">1016</span>, <span class="keyword">null</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 检查是否已登陆,不会被拦截</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@RequestMapping</span>(value = <span class="string">"/isLogin"</span>, method = RequestMethod.GET)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> AjaxResult <span class="title">isLogin</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (<span class="keyword">null</span> != SecurityUtils.getSubject().getPrincipal()) &#123;</span><br><span class="line">	        <span class="comment">//已经登陆</span></span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">200</span>, <span class="string">"true"</span>);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">	        <span class="comment">//未登录</span></span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">200</span>, <span class="string">"false"</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 验证码图片生成</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@param</span> request</span></span><br><span class="line"><span class="comment">     * <span class="doctag">@return</span></span></span><br><span class="line"><span class="comment">     * <span class="doctag">@throws</span> IOException</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="meta">@RequestMapping</span>(value = <span class="string">"/getVCodePic"</span>, method = RequestMethod.GET)</span><br><span class="line">    <span class="function"><span class="keyword">public</span> AjaxResult <span class="title">getVCodePic</span><span class="params">(HttpServletRequest request)</span> <span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">        <span class="comment">//验证码生成工具</span></span><br><span class="line">        Cage cage = <span class="keyword">new</span> Cage();</span><br><span class="line">        <span class="comment">//获取长度为4随机字符串</span></span><br><span class="line">        MyVCode myVCode = <span class="keyword">new</span> MyVCode();</span><br><span class="line">        String vCode = myVCode.getVCode(<span class="number">4</span>);</span><br><span class="line">        request.getSession().setAttribute(<span class="string">"vCode"</span>, vCode);</span><br><span class="line">        ByteArrayOutputStream outputStream = <span class="keyword">new</span> ByteArrayOutputStream();</span><br><span class="line">        cage.draw(vCode, outputStream);</span><br><span class="line">        BASE64Encoder encoder = <span class="keyword">new</span> BASE64Encoder();</span><br><span class="line">        String data = encoder.encode(outputStream.toByteArray());</span><br><span class="line">        outputStream.close();</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> AjaxResult(<span class="number">200</span>, <span class="string">"验证码"</span>, data);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="Vue判断是否已经登陆"><a href="#Vue判断是否已经登陆" class="headerlink" title="Vue判断是否已经登陆"></a>Vue判断是否已经登陆</h3><p>main.js中配置</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> axios <span class="keyword">from</span> <span class="string">'axios'</span></span><br><span class="line"><span class="keyword">import</span> router <span class="keyword">from</span> <span class="string">'./router'</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//axios拦截响应</span></span><br><span class="line">axios.interceptors.response.use(<span class="function"><span class="keyword">function</span> (<span class="params">response</span>) </span>&#123;</span><br><span class="line">  <span class="comment">// Do something with response data</span></span><br><span class="line">  <span class="keyword">if</span>(response.data.errcode == <span class="number">200</span>)&#123;</span><br><span class="line">    <span class="keyword">return</span> response;</span><br><span class="line">  &#125;<span class="keyword">else</span> <span class="keyword">if</span>(response.data.errcode == <span class="number">210</span>)&#123;</span><br><span class="line">    <span class="comment">//未登录，跳转至登陆页</span></span><br><span class="line">    router.push(<span class="string">"/login"</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="built_in">Promise</span>.reject(response.data.info);</span><br><span class="line">  &#125; <span class="keyword">else</span> <span class="keyword">return</span> <span class="built_in">Promise</span>.reject(response.data.info + <span class="string">"；错误码："</span> + response.data.errcode);</span><br><span class="line">&#125;, <span class="function"><span class="keyword">function</span> (<span class="params">error</span>) </span>&#123;</span><br><span class="line">  <span class="comment">// Do something with response error</span></span><br><span class="line">  <span class="built_in">console</span>.log(error);</span><br><span class="line">  <span class="keyword">return</span> <span class="built_in">Promise</span>.reject(<span class="string">"网络请求错误"</span>);</span><br><span class="line">&#125;);</span><br><span class="line"><span class="comment">//跳转前处理</span></span><br><span class="line">router.beforeEach(<span class="function"><span class="keyword">function</span> (<span class="params">to,from,next</span>) </span>&#123;</span><br><span class="line">  <span class="comment">// 已登录的情况再去登录页，跳转至首页</span></span><br><span class="line">  <span class="keyword">if</span> (to.name === <span class="string">'Login'</span>) &#123;</span><br><span class="line">    Vue.prototype.$ajax.get(<span class="string">'/user/isLogin'</span>).then(<span class="function">(<span class="params">res</span>) =&gt;</span> &#123;</span><br><span class="line">      <span class="keyword">if</span> (res.data.info === <span class="string">'true'</span>)&#123;</span><br><span class="line">        router.push(<span class="string">'/'</span>);</span><br><span class="line">      &#125;</span><br><span class="line">    &#125;)</span><br><span class="line">  &#125;</span><br><span class="line">  next();</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
        </div>

        <blockquote class="post-copyright">
    
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2018-01-29T12:48:27.208Z" itemprop="dateUpdated">2018-01-29 20:48:27</time>
</span><br>


        
        大家有问题或建议的话可以评论或者用邮箱与我交流~<a href="/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/" target="_blank" rel="external">http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/</a>
        
    </div>
    
    <footer>
        <a href="http://lfxiui.gitee.io">
            <img src="/img/avatar.jpg" alt="lfxiui">
            lfxiui
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/shiro/">shiro</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/spring-boot/">spring boot</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vue/">vue</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/登陆验证/">登陆验证</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&title=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&pic=http://lfxiui.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&title=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&source=尘世中一个迷途的小码农" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&via=http://lfxiui.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2018/02/19/Vue+Google地图：批量站点显示、隐藏/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Vue+Google地图：批量站点显示、隐藏</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2018/01/29/JSON数据格式化/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">JSON数据格式化</h4>
      </a>
    </div>
  
</nav>



    


<section class="comments" id="comments">
    <div id="disqus_thread"></div>
    <script>
    var disqus_shortname = 'true';
    lazyScripts.push('//' + disqus_shortname + '.disqus.com/embed.js')
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>













</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢大爷~
        <i class="icon icon-quote-right"></i>
    </h3>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/img/wechat.png" alt="打赏二维码">
        </div>
        
        <label class="reward-toggle">
            <input id="rewardToggle" type="checkbox" class="reward-toggle-check"
                data-wechat="/img/wechat.png" data-alipay="/img/alipay.jpg">
            <div class="reward-toggle-ctrol">
                <span class="reward-toggle-item wechat">微信</span>
                <span class="reward-toggle-label"></span>
                <span class="reward-toggle-item alipay">支付宝</span>
            </div>
        </label>
        
    </div>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>lfxiui &copy; 2015 - 2020</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&title=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&pic=http://lfxiui.gitee.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&title=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&source=尘世中一个迷途的小码农" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《spring boot+shiro+vue前后端分离登陆验证》 — 阿喜的博客&url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/&via=http://lfxiui.gitee.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://lfxiui.gitee.io/2018/01/29/spring boot+shiro+vue前后端分离登陆验证/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = 'Waiting...';
            clearTimeout(titleTime);
        } else {
            document.title = 'Running...';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
